Skip to content

Conversation

@floura-angel
Copy link
Contributor

PR Summary

Bug in :meth:DataFrame.resample.asfreq where fixed-frequency indexes with origin ignored alignment
and returned incorrect values. Now origin and offset are respected. (:issue:62725)

@floura-angel floura-angel changed the title fix honor orgin in asfreq BUG: resample with asfreq ignores origin if the dataframe has a fixed frequency #62725 Oct 20, 2025
@floura-angel floura-angel marked this pull request as ready for review October 20, 2025 00:39
Comment on lines 1004 to 1010
exp_idx = pd.to_datetime(
[
"2025-10-17 17:15:00",
"2025-10-17 17:16:00",
"2025-10-17 17:17:00",
]
).astype(result.index.dtype) # match time unit (s/us/ns)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you construct a DatetimeIndex with freq= so we don't need to use check_freq=False?

@mroeschke mroeschke added Frequency DateOffsets Resample resample method labels Oct 20, 2025
Comment on lines 1008 to 1010
date_range("2025-10-17 17:15:00", periods=3, freq="min").astype(
result.index.dtype
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you pass a list of Timestamps to the pd.DatetimeIndex constructor and pass the dtype as well? (For context, tests should minimize the use of extraneous APIs where possible.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, updated. Thanks

@mroeschke mroeschke added this to the 3.0 milestone Nov 4, 2025
@mroeschke mroeschke merged commit a3c208d into pandas-dev:main Nov 4, 2025
42 checks passed
@mroeschke
Copy link
Member

Thanks @floura-angel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frequency DateOffsets Resample resample method

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: resample with asfreq ignores origin if the dataframe has a fixed frequency

3 participants